import asyncio
import time

import objects as objects
from django.test import TestCase

# Create your tests here.
import pickle

from testviewset.models import User
from utils.redisMethod import setToken, getTokenUser

# dict = {"user": "123", "pwd": "345", "tel": "456"}
# user = User(**dict)
# setToken("fuckToken", user)
#
# user = getTokenUser("fuckToken")
# print(user.__dict__)


def my_fun(fun):
    def wrapper(a, b):
        a = a + 1
        b = b + 1
        return fun(a, b)
    return wrapper


@my_fun
def add(c, d):
    return c+d


def PIC():
    PI = 0
    N = 1000
    for n in range(int(N)):
        PI += 1 / pow(16, n) * (4 / (8 * n + 1) - 2 / (8 * n + 4) - 1 / (8 * n + 5) - 1 / (8 * n + 6))
    print(PI)


async def timesleep():

    time.sleep(5)


# class Animal(object):
#     def run(self):
#         print('Animal run.')
#
#     def eat(self):
#         print('Animal eat.')
#
#
# class Dog(Animal):
#     def run(self):
#         print('Dog run.')
#
#     def eat(self):
#         print('Dog eat.')
#
#
# class Cat(Animal):
#     def run(self):
#         print('Cat run.')
#
#     def eat(self):
#         print('Cat eat.')

if __name__ == "__main__":
    # print(add(3, 4))
    # PIC()
    # loop = asyncio.new_event_loop()
    # loop = asyncio.get_event_loop()
    # print("开始")
    # loop.run_until_complete(timesleep())
    # print("结束")
    # for i in range(7):
    #     print(i)
    # a = {'id': 11}
    # print(a.pop('id'))
    # print(a.pop('id'))
    a = Animal()

